package com.zpark.cloud.alibaba.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

/**
 * @PackageName: com.zpark.cloud.alibaba.controller
 * @ClassName: TestController
 * @Description:
 * @author: RZS
 * @date: 2023/6/25  15:40
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/t1.do")
    public String test01(HttpServletRequest request){
        // 获取请求头的值
        Enumeration<String> headers = request.getHeaders("X-Request-red");
        String val = "";
        while (headers.hasMoreElements()){
            val = headers.nextElement();
        }
        // 获取请求参数
        String uname = request.getParameter("uname");
        return "<h1>X-Request-red: "+val+", uname: "+uname+"</h1>";
    }
}
